package com.noble.meether.ui.point.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.TextView;

import com.noble.meether.R;
import com.noble.library.widget.RecyclerView.base.BaseRecyclerViewAdapter;
import com.noble.library.widget.RecyclerView.base.BaseRecyclerViewHolder;
import com.noble.meether.ui.point.bean.Point;

/**
 * Created by Su on 2018/6/27.
 */
public class MyPointAdapter extends BaseRecyclerViewAdapter<Point> {

    private Context mContext;

    public MyPointAdapter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public int[] getItemLayouts() {
        return new int[]{R.layout.item_point_list};
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return super.onCreateViewHolder(parent, viewType);
    }

    @Override
    public void onBindRecycleViewHolder(BaseRecyclerViewHolder viewHolder, int position) {
        MyViewHolder vh = new MyViewHolder(viewHolder);
        final Point info = getItem(position);

        vh.tv_point.setText(info.getMinStar() + " - " + info.getMaxStar() + "分");
        if (info.getAmount() > 0) {
            vh.tv_content.setText(info.getAmount() + "元/分钟");
        } else {
            vh.tv_content.setText("无奖励");
        }
    }

    @Override
    public int getRecycleViewItemType(int position) {
        return 0;
    }

    class MyViewHolder {
        TextView tv_point, tv_content;

        public MyViewHolder(BaseRecyclerViewHolder convertView) {
            initView(convertView);
        }

        private void initView(BaseRecyclerViewHolder convertView) {
            tv_point = convertView.findViewById(R.id.tv_point);
            tv_content = convertView.findViewById(R.id.tv_content);
        }
    }
}